local MODULE = {}
	MODULE.Name = "AntiBan -- NameChanger"
	MODULE.Hooks = {}
	
// Variables
	local nicks = {}
	local self = LocalPlayer()
	local refresh = 0
	local time = 5
	local built = false
	local boo = false
	
// Functions

	function MODULE.Rebuild()
	
		for i = 1, table.Count( nicks ) do
		
			table.remove( nicks, i )
			
		end
		
	end

	function MODULE.BuildNicks()
	
		if not self:IsValid() then return false end
	
		MODULE.Rebuild()
	
		for k,v in pairs(player.GetAll()) do
		
			if v:Nick() != self:Nick() then
			
				local lol = string.Replace( v:Nick(), " ", "_" ) .. "_"
			
				table.insert( nicks, lol .. string.char( 03 ) )
				
			end
			
		end
		
	end
	
	function MODULE.NameChange()
	
		if active then
		
			if not built then MODULE.BuildNicks() built = true end
		
			if not nicks then return false end
	
			local rand = math.random(1, table.Count( nicks ) )
			
			RunConsoleCommand( "setinfo", "name", nicks[rand] )
				
		end
		
		if CurTime() >= refresh then
		
			MODULE.BuildNicks()
			
			refresh = CurTime() + time
			
		end
		
	end
	
	function MODULE.Toggle()
	
		if not boo then
		
			timer.Create( "LOLNAME", 0, 0, function()
				if table.Count( nicks ) > 0 then
					local lol = nicks[math.random(1, table.Count(nicks))]
					print( "setinfo name " .. lol )
					RunConsoleCommand("setinfo", "name", "TESTLOL")
				else
					RunConsoleCommand("setinfo", "name", "Prefan")
				end
			end)
			boo = true
			
		elseif boo then
		
			timer.Destroy( "LOLNAME" )
			boo = false
			
		end
		
	end
	
// Register and Hook

	concommand.Add( "PAB_ToggleName", MODULE.Toggle )
	
	MODULE.Hooks[MODULE.NameChange] = "Think"
	PAB.Register( MODULE )